import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Schema({ timestamps: { createdAt: 'createTime', updatedAt: 'updateTime' } })
export class shaderList {
  @Prop({ required: true, type: Object })
  user: { id: string; name: string }; //作者
  @Prop({ required: true, type: String })
  label: 'shader' | 'effect' | 'game' | 'model' | 'home'; //标签

  @Prop({ required: true, type: String })
  title: string; // 视频名称

  @Prop({ required: true, type: String })
  description: string; // 视频描述

  @Prop({ type: Array, default: 0, required: true })
  videoInfo: { name: string, duration: string, size: string, url: string }; // 视频文件的基本信息

  @Prop({ type: String, default: 0, required: true })
  coverUrl: string; // 封面图

  @Prop({ type: Date, index: true })
  createTime: Date;

  @Prop({ type: Date, index: true })
  updateTime: Date;
}

export type shaderListDocument = shaderList & Document;

export const shaderListSchema = SchemaFactory.createForClass(shaderList);

shaderListSchema.index({ createTime: -1 });
shaderListSchema.index({ lastLogin: -1 });